<?php
class User_Model_Users extends Zen_List {
	public function __construct() {
		$this->table = new Zend_Db_Table ( 'user' );
	}

	public function beforeCreate($params){
		if(isset($params['pass'])){
			$params['pass']=Zen_User::hashpass($params['pass']);
		}
		return $params;
	}

	public function beforeUpdate($id, $params){
		if(isset($params['pass'])){
			$params['pass']=Zen_User::hashpass($params['pass']);
		}
		return $params;
	}

	public function afterChange(){
		Cache_Model_Clear::clear('acl');
		$acl=Zen_Acl::getInstance();
	}
	
	public function getCurrent() {
		if (! Zen_User::isLoged())
			return false;
		$user_id = Zen_User::getId();
		$res = $this->select()->getOne("id=$user_id");
		if (! $res)
			return false;
		$property = ($res['property']) ? unserialize($res['property']) : false;
		if ($property && is_array($property))
			foreach ($property as $key => $value)
				$res[$key] = $value;
		return $res;
	}

}
?>